﻿<UserControl x:Class="DACU.UserControls.Player.PlayList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" Loaded="UserControl_Loaded">
	<UserControl.Resources>
		<Style x:Key="NormalRowEvent" TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource NormalRow}">
			<EventSetter Event="MouseDoubleClick" Handler="HandleDoubleClick" />
		</Style>
		<Style x:Key="AlternativeRowEvent" TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource AlternativeRow}">
			<EventSetter Event="MouseDoubleClick" Handler="HandleDoubleClick" />
		</Style>
		<Style x:Key="CurrentPlaysRowEvent" TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource CurrentPlaysRow}">
			<EventSetter Event="MouseDoubleClick" Handler="HandleDoubleClick" />
		</Style>
	</UserControl.Resources>
    <Grid Margin="2">
		<Grid.RowDefinitions>
			<RowDefinition />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		<TabControl Name="tabControl1" x:FieldModifier="private" Padding="0,4">
			<TabItem Header="{Binding Name}" Name="tabItem1" x:FieldModifier="private">
				<Grid><!--MouseDoubleClick="lvPlayList_MouseDoubleClick"-->
					<ListView Name="lvPlayList" x:FieldModifier="private" ItemContainerStyleSelector="{DynamicResource PlayListStyleSelector}" AlternationCount="2" AllowDrop="True" Drop="lvPlayList_Drop" HorizontalContentAlignment="Stretch" ItemsSource="{Binding}">
						<ListView.ItemTemplate>
							<DataTemplate>
								<Grid>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="Auto" SharedSizeGroup="column1" />
										<ColumnDefinition />
										<ColumnDefinition Width="Auto" SharedSizeGroup="column3" />
									</Grid.ColumnDefinitions>
									<TextBlock Margin="0,2,5,2">
										<TextBlock.Text>
											<MultiBinding Converter="{StaticResource ResourceKey=ItemToIndex}">
												<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType=ListView, AncestorLevel=1}" Path="Items"/>
												<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType=ListViewItem, AncestorLevel=1}"/>
											</MultiBinding>
										</TextBlock.Text>
									</TextBlock>
									<StackPanel Orientation="Horizontal" Grid.Column="1" Margin="0,2">
										<TextBlock Text="{Binding Artist}" />
										<TextBlock Text=" - ">
											<TextBlock.Visibility>
												<MultiBinding Converter="{StaticResource ResourceKey=TrackToVisibility}">
													<Binding Path="Artist" />
													<Binding Path="Title" />
												</MultiBinding>
											</TextBlock.Visibility>
										</TextBlock>
										<TextBlock Text="{Binding Title}" />
									</StackPanel>
									<TextBlock Text="{Binding Duration}" Grid.Column="2" Margin="5,2,2,2"></TextBlock>
								</Grid>
								<!--<DockPanel Background="#FFAD4949" LastChildFill="False">
									<TextBlock>
										<TextBlock.Text>
											<MultiBinding Converter="{StaticResource ResourceKey=ItemToIndex}">
												<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType=ListView, AncestorLevel=1}" Path="Items"/>
												<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType=ListViewItem, AncestorLevel=1}"/>
											</MultiBinding>
										</TextBlock.Text>
									</TextBlock>
									<StackPanel Orientation="Horizontal">
										<TextBlock Text="{Binding Artist}" />
										<TextBlock Text=" - ">
											<TextBlock.Visibility>
												<MultiBinding Converter="{StaticResource ResourceKey=TrackToVisibility}">
													<Binding Path="Artist" />
													<Binding Path="Title" />
												</MultiBinding>
											</TextBlock.Visibility>
										</TextBlock>
										<TextBlock Text="{Binding Title}" />
									</StackPanel>
									<TextBlock Text="{Binding Duration}" DockPanel.Dock="Right"></TextBlock>
								</DockPanel>-->
							</DataTemplate>
						</ListView.ItemTemplate>
						<!--<ListView.View>
							<GridView>
								<GridViewColumn Header="#" Width="30">
									<GridViewColumn.CellTemplate>
										<DataTemplate>
											<TextBlock>
												<TextBlock.Text>
													<MultiBinding Converter="{StaticResource ResourceKey=ItemToIndex}">
														<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType=ListView, AncestorLevel=1}" Path="Items"/>
														<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType=ListViewItem, AncestorLevel=1}"/>
													</MultiBinding>
												</TextBlock.Text>
											</TextBlock>
										</DataTemplate>
									</GridViewColumn.CellTemplate>
								</GridViewColumn>
								<GridViewColumn Header="Artist" DisplayMemberBinding="{Binding Artist}">
									<GridViewColumn.CellTemplate>
										<DataTemplate>
											
										</DataTemplate>
									</GridViewColumn.CellTemplate>
								</GridViewColumn>
								<GridViewColumn Header="Title" DisplayMemberBinding="{Binding Title}"/>
								<GridViewColumn Header="Duration" DisplayMemberBinding="{Binding Duration}"/>
							</GridView>
						</ListView.View>-->
					</ListView>
				</Grid>
			</TabItem>
		</TabControl>
		<Grid Grid.Row="1" Name="grid1" x:FieldModifier="private">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition />
				<ColumnDefinition />
				<ColumnDefinition />
			</Grid.ColumnDefinitions>
			<Grid Grid.ColumnSpan="3">
				<Grid.ColumnDefinitions>
					<ColumnDefinition />
					<ColumnDefinition />
				</Grid.ColumnDefinitions>
				<Button Name="bAdd" x:FieldModifier="private" Content="Add" Click="bAdd_Click" ContextMenuOpening="bAdd_ContextMenuOpening">
					<Button.ContextMenu>
						<ContextMenu Name="AddMenu" x:FieldModifier="private">
							<MenuItem Header="Vkontakte Audio" Click="VKMenuItemClick" />
							<MenuItem Header="File" Click="FileMenuItemClick"/>
							<MenuItem Header="Url" Click="UrlMenuItemClick"/>
						</ContextMenu>
					</Button.ContextMenu>
				</Button>
				<Button Name="bDelete" x:FieldModifier="private" Content="Delete" Grid.Column="1" Click="bDelete_Click" />
			</Grid>
			<Button Name="bLoad" x:FieldModifier="private" Content="Load" Click="bLoad_Click" Grid.Row="1" />
			<Button Name="bSave" x:FieldModifier="private" Content="Save" Grid.Column="1" Click="bSave_Click" Grid.Row="1" />
			<Button Name="bClear" x:FieldModifier="private" Content="Clear" Grid.Column="2" Click="bClear_Click" Grid.Row="1" />
		</Grid>
	</Grid>
</UserControl>
